# Maintainer: Lothar Serra Mari <serra@scummvm.org>

_realname=scummvm
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=2.0.0
pkgrel=2
pkgdesc="A program which allows you to run certain classic graphical point-and-click adventure games (mingw-w64)"
arch=('any')
url='https://www.scummvm.org/'
license=("GPL")
makedepends=("${MINGW_PACKAGE_PREFIX}-binutils"
             "${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-gcc-libs"
             "${MINGW_PACKAGE_PREFIX}-pkg-config")
depends=("${MINGW_PACKAGE_PREFIX}-faad2"
         "${MINGW_PACKAGE_PREFIX}-freetype"
         "${MINGW_PACKAGE_PREFIX}-flac"
         "${MINGW_PACKAGE_PREFIX}-fluidsynth"
         "${MINGW_PACKAGE_PREFIX}-libjpeg-turbo"
         "${MINGW_PACKAGE_PREFIX}-libogg"
         "${MINGW_PACKAGE_PREFIX}-libvorbis"
         "${MINGW_PACKAGE_PREFIX}-libmad"
         "${MINGW_PACKAGE_PREFIX}-libmpeg2-git"
         "${MINGW_PACKAGE_PREFIX}-libtheora"
         "${MINGW_PACKAGE_PREFIX}-libpng"
         "${MINGW_PACKAGE_PREFIX}-nasm"
         "${MINGW_PACKAGE_PREFIX}-readline"
         "${MINGW_PACKAGE_PREFIX}-SDL2"
         "${MINGW_PACKAGE_PREFIX}-zlib")
source=("https://www.scummvm.org/frs/scummvm/${pkgver}/scummvm-${pkgver}.tar.xz"
         0001-mingw-w64-compilation-fix.patch)
sha256sums=('9784418d555ba75822d229514a05cf226b8ce1a751eec425432e6b7e128fca60'
            '163b95944e0dcdf358930a842fb2e56cd005bd53ee541fa9dca20b0777cfa327')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
  patch -p1 ${srcdir}/${_realname}-${pkgver}/backends/platform/sdl/sdl-sys.h < ${srcdir}/0001-mingw-w64-compilation-fix.patch
}

build() {
  mkdir -p "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"
  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --enable-release \
    --enable-optimizations \
    --disable-cloud \
    --disable-debug

  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR="${pkgdir}" install
}